home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
9-Digit Zip Code Directory
/
9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO
/
z4src.zip
/
Z4CSPRE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1995-08-20
|
4KB
|
154 lines
//----------------------------------------------------------------------------
// MODULE DESCRIPTION
//
// Module: z4cspre.c
// Title: 9-Digit ZIP Code Directory -- on CD-ROM
// Notice: John M. Weeder
// Copyright (c) 1993. All rights reserved.
// This module contains proprietary information and should be
// treated as confidential.
//
//----------------------------------------------------------------------------
// MAINTENANCE HISTORY
//
// $Workfile$
// $Revision$
// $Author$
// $Date$
// $Log$
//
//----------------------------------------------------------------------------
// MODULE NARRATIVE
//
// This module contains the program entry point for
//
// The code in this module may be written in C++ or C.
//
// This module is portable to:
// DOS 3.X+
// MS Windows 3.X+
// OS/2 2.X+
// OS/2 2.0 PM
//
// The following compilers are supported:
// MSC 6.0A
// MSC/C++ 7.0
// Borland C++ 3.1 for DOS
// Borland C++ 1.0 for OS/2 2.X
//
//----------------------------------------------------------------------------
#include <z4.h>
//----------------------------------------------------------------------------
// Stack size
//----------------------------------------------------------------------------
#if COMPILER_BORLAND && (OS_DOS || OS_WINDOWS)
unsigned _stklen = 0x4000;
#endif
//----------------------------------------------------------------------------
// Globals
//----------------------------------------------------------------------------
//
// A useless string which is simply embedded in the executable.
//
PSZ __pszCredits__ = "Written by John M Weeder, 1993";
//
// This should contain a program description which will be displayed as
// part of the program's help text.
//
static PCSZ pcszDescription =
"This program pre-processes the city state file.";
//
// Program command line options
//
static DATACFG dcfg;
static CHAR szConfig[MAX_PATH] = "z4cs";
static BS_CMDOPT acmdopt[] =
{
{ "config", (PVOID)szConfig, CMDOPT_FILESPECR(80), "Configuration file name."},
{ "input", (PVOID)dcfg.szInput, CMDOPT_FILESPEC(80), "Input file name."},
BS_CMDOPT_NULL,
};
//----------------------------------------------------------------------------
// Description:
// Parameters:
// Returns:
//----------------------------------------------------------------------------
BOOL FN_E Z4CSPre(PDATACFG pcfg, PSZ _FAR_ *apsz, PBYTE pb, SIZET cb)
{
static SIZET cPof;
static SIZET cState;
static BOOL fInit = FALSE;
static PZ4_PF_TBL ppf_tbl = NULL;
NOTUSED(pb);
NOTUSED(cb);
if (apsz == NULL) {
if (!fInit) {
Z4PofCreate(&ppf_tbl, Z4_PF_TBL_DISCARD_MAX);
fInit = TRUE;
} else {
Z4PofWrite(ppf_tbl, Z4_PF_TBL_DISCARD);
Z4PofDestroy(ppf_tbl);
}
cPof = DataField(pcfg, "finance");
cState = DataField(pcfg, "state_abbrev");
return FALSE;
}
// Check state code
if (Z4FindState(apsz[cState]) != Z4_ST_INVALID)
return FALSE;
Z4PofAdd(ppf_tbl, apsz[cPof]);
return FALSE;
}
//----------------------------------------------------------------------------
// Description: main() - Program entry point
// Parameters: Standard C parameters
// Returns: DOS return code.
//----------------------------------------------------------------------------
int main(int argc, char **argv)
{
static BS_CFG cfg = CFG_DFT;
SHORT retval;
//
// Initialize base library
//
BaseLibraryInitialize(argc, argv, &cfg);
BaseTitle("$Revision: 93.1 $", __DATE__, __TIME__, "City/State File Preprocess Utility");
if (!BaseTitleHelp(acmdopt, pcszDescription,0))
return 99;
DioSetDataPath(getenv("DATA"));
dcfg.fInit = TRUE;
if (!DataConfigRead(szConfig, &dcfg))
{
Output("Failed reading configuration file.\n");
goto ERROR_EXIT;
}
if (!DataPreProcess(&dcfg, Z4CSPre))
{
Output("Failed preprocessing file.\n");
goto ERROR_EXIT;
}
retval = 0;
ERROR_EXIT:
DioCloseAll();
return retval;
}
//----------------------------------------------------------------------------
//------------------------------- End of File --------------------------------
//----------------------------------------------------------------------------